package com.ruoyi.huanghefd.controller;

import com.alibaba.fastjson2.JSON;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.huanghefd.domain.ContactsheetRj;
import com.ruoyi.huanghefd.service.ContactsheetRjService;
import com.ruoyi.huanghefd.utils.PageBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


/**
 * @Author gnplum
 * @Date 2023/11/13 11:53
 * @PackageName:com.ruoyi.huanghefd.controller
 * @ClassName: ContactsheetRjController
 * @Description: TODO
 * @Version 1.0
 */
@RestController
@RequestMapping("/huanghefd")
public class ContactsheetRjController {
    private static final Logger log = LoggerFactory.getLogger(ContactsheetRjController.class);

    @Resource
    private ContactsheetRjService contactsheetRjService;

    /**
     * @Author gnplum
     * @Description //新增 联系单*（热机检修工作停电、送电）
     * @Date 9:48 2023/11/13
     * @param contactsheetRj
     * @return com.ruoyi.huanghefd.domain.ResultWS
     **/
    @PostMapping("/addContactsheetRJ")
    public AjaxResult addContactsheetRJ(@RequestBody ContactsheetRj contactsheetRj){
        log.info(">> 新增联系单*（热机检修工作停电、送电）-入参==" + JSON.toJSONString(contactsheetRj));
        AjaxResult ajax = contactsheetRjService.addContactsheetRj(contactsheetRj);
        log.info("<< 新增联系单*（热机检修工作停电、送电）-返回==" + ajax.toString());
        return ajax;
    }

    /**
     * @Author gnplum
     * @Description //删除 联系单*（热机检修工作停电、送电）
     * @Date 15:22 2023/10/31
     * @param cnCode
     * @return com.ruoyi.common.core.domain.AjaxResult
     **/
    @PostMapping(value = "/delContactsheetRJ")
    public AjaxResult delContactsheetRJ(@RequestParam(required = false,value = "cnCode") String cnCode){
        log.info(">> 删除联系单*（热机检修工作停电、送电）-入参 apId==" + cnCode);
        if(cnCode.isEmpty()){
            return AjaxResult.success("请点选要删除的联系单*（热机检修工作停电、送电）");
        }
        AjaxResult ajax = contactsheetRjService.delContactsheetRj(cnCode);
        log.info(">> 删除联系单*（热机检修工作停电、送电）-返回==" + ajax);
        return ajax;
    }

    /**
     * @Author gnplum
     * @Description //修改 联系单*（热机检修工作停电、送电）
     * @Date 15:47 2023/10/31
     * @param contactsheetRj
     * @return com.ruoyi.common.core.domain.AjaxResult
     **/
    @PostMapping(value = "/uptContactsheetRJ")
    public AjaxResult uptContactsheetRJ(@RequestBody ContactsheetRj contactsheetRj){
        log.info(">> 修改联系单*（热机检修工作停电、送电）入参 ==" + JSON.toJSONString(contactsheetRj));
        AjaxResult ajax = contactsheetRjService.uptContactsheetRj(contactsheetRj);
        log.info(">> 修改联系单*（热机检修工作停电、送电）-返回 ==" + ajax);
        return ajax;
    }

    /**
     * @Author gnplum
     * @Description //查询 联系单*（热机检修工作停电、送电）
     * @Date 9:48 2023/10/31
     * @param cnCode,cnState
     * @return com.ruoyi.common.core.domain.AjaxResult
     **/
    @PostMapping(value = "/queryContactsheetRJ")
    public AjaxResult queryContactsheetRJ(@RequestParam(required = false,value = "cnCode") String cnCode,@RequestParam(required = false,value = "cnState") String cnState,@RequestParam(required = false,value = "userId") String userId,@RequestParam(required = false,value = "mailType") String mailType){
        log.info(">> 查询联系单*（热机检修工作停电、送电）-入参==" + cnCode + "," + "," + cnState + "," + userId + "," + mailType);
        AjaxResult ajax= contactsheetRjService.queryContactsheetRjs(cnCode,cnState,userId,mailType);//mailType 1-收件箱 2-发件箱
        log.info(">> 查询联系单*（热机检修工作停电、送电）-返回==" + ajax);
        return ajax;
    }
    /**
     * @Author gnplum
     * @Description //查询 联系单*（热机检修工作停电、送电） 分页
     * @Date 15:53 2024/1/3
     * @param cnCode
     * @param cnState
     * @param userId
     * @param mailType
     * @param pageNum
     * @param pageSize
    * @return com.ruoyi.common.core.domain.AjaxResult
    **/
    @PostMapping(value = "/queryContactsheetRJ1")
    public PageBean queryContactsheetRJ(@RequestParam(required = false,value = "cnCode") String cnCode, @RequestParam(required = false,value = "cnState") String cnState, @RequestParam(required = false,value = "userId") String userId, @RequestParam(required = false,value = "mailType") String mailType, @RequestParam(value = "pageNum") int pageNum, @RequestParam(value = "pageSize") int pageSize){
        log.info(">> 查询联系单*（热机检修工作停电、送电）-入参==" + cnCode + "," + "," + cnState + "," + userId + "," + mailType);
        PageBean ajax= contactsheetRjService.queryContactsheetRjsByPage(cnCode,cnState,userId,mailType,pageNum,pageSize);//mailType 1-收件箱 2-发件箱 3-草稿箱
        log.info(">> 查询联系单*（热机检修工作停电、送电）-返回==" + ajax);
        return ajax;
    }
}
